home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / js.zip / UT.JS < prev    next >
Text File  |  1992-12-30  |  4KB  |  113 lines

  1. NB.  This file can be used as a script input file to J Version 6.1
  2. NB.  December 1992
  3.  
  4. NB.  Donald B. McIntyre
  5. NB.  Luachmhor, 1 Church Road
  6. NB.  KINFAUNS, PERTH PH2 7LD
  7. NB.  SCOTLAND - U.K.
  8. NB.  Telephone:  In the UK:      0738-86-726
  9. NB.  From USA and Canada:   011-44-738-86-726
  10. NB.  email:  donald.mcintyre@almac.co.uk
  11.  
  12. apv=. {.@] + [* (i.@>.@>:)@(%~ |@-/)
  13. NB. Arithmetic Progression Vector:   0.5 apv _2 5
  14.  
  15. bi=. <"_1                 NB. Box items
  16. boxchar=. 9!:6            NB. Enquire on current setting of box characters
  17. NB. 9!:7 ]218 194 191  195 197 180  192 193 217  179 196 { a. NB. reset box
  18. NB. 9!:7 (9$'+'),'|-'     NB. Set alternative box characters
  19.  
  20. by=. ' '&;@,.@[,.]
  21. clean=. ] * (<:|)         NB. Set to zero. Tolerance on left
  22.  
  23. copy=. 2!:4&<          NB. Copy single item.   'apv' copy 'ut.ws'
  24. copy=. ;:@[ 2!:4 <@]   NB. Copy item(s). 'qrl setrl' copy 'ut.ws'
  25. copyws=. 2!:1@< 2!:4 < NB. Copy all items from locale.  copyws 'ut.ws'
  26.  
  27. (;:'lf cr eof')=. 10 13 26{a.
  28. NB. Carriage Return, Line Feed, End of File
  29.  
  30. E=. ].@([.(+&)) - ].      NB. c <- c c c ; c <- c v c
  31. S=. ([.(%&))@E            NB. Secant slope
  32. S=. 'S' f.
  33. D=. 1e_8 S                NB. a <- n c    Derivative adverb
  34. D=. 'D' f.
  35. NB.(1 E *:) 1 2 3 4
  36. NB. (0.01 S *:) 1 2 3 4
  37. NB. *: D _2 _1 0 1 2 3
  38.  
  39. dfr=. rfd^:_1             NB. Degrees From Radians
  40. diag=. (<0 1)&|:          NB. Diagonal
  41. dir=. 0!:0 'dir'          NB. Directory of current subdirectory
  42. display=. 9!:3                
  43. display 2 4 5             NB. Three types of display
  44. drop=. 1!:55@<            NB. Drop 'junk.fil'
  45. each=. &.>                NB. # each 'abc';'defg';'hijkl'
  46. edit=. 8!:9               NB. Edit a character string
  47. erase=. 4!:55@;:          NB. Erase named object(s) erase: 'f g h'
  48. exp=. /:@\:@[ { #@[ {. ]  NB. Expand.   1 0 1 exp 7 8
  49. fsize=. 1!:4@<            NB. File size
  50. gauss=. {.@] + {:@] * -&6@%&1e9@(+/@?@($&1e9)@(12&,))@[
  51. NB.  100 gauss 0 1 NB. 100 normally distributed values mean 0, sd 1
  52. getedit=. edit@read       NB. Read a file into the J editor
  53. host=. 0!:0               NB. host 'dir c:\*.bat'
  54. im=. =@i.                 NB. Identity Matrix
  55. inv=. ^:_1                NB. Inverse function
  56. ip=. +/ .*                NB. Inner Product
  57. limit=. ^:_
  58. linear=. 5!:5@<           NB. Linear representation 
  59.  
  60. noun=. 2 [ verb=. 3 [ adverb=. 4 [ conjunction=. 5
  61. names=. >@(4!:1)  NB. 'e' names verb,adverb
  62. NB. Optional left argument:  initial letter(s)
  63.  
  64. over=. ({.,.@;}.)@":@,
  65. qrl=. 9!:0                NB. Query Random Link:  qrl 0
  66. read=. 1!:1&<             NB. x=. read 'out1.fil'
  67. rfd=. %&180@o.            NB. Radians From Degrees
  68.  
  69. rlfe=. >@((#~ ~:&lf)&.>@(<;.1~ =&lf))
  70. NB. Remove Line-Feeds from Edited lines:  ]x=. rlfe editor ''
  71.  
  72. round=. [ * <.@+&0.5@%~   NB. Round y to nearest x
  73. NB. (10^-i.6) round o.1
  74. NB. 5 10 50 100 150 5000 10000 25000 round 123456
  75. NB.  x=. 5 50 500 5000 [y=. 646464 64646 6464 646
  76. NB.  y by x over |: x round"0 1 y
  77.  
  78. save=. 2!:2@<    NB. Save all Global Names.  save 'my.ws'
  79. setrl=. 9!:1     NB. Set Random Link:  setrl 7^5
  80. table=. '[ by ] over [ x.f. / ]' : 1   NB.  + table i.5
  81. time=. 6!:0      NB. Time stamp
  82. timeit=. 6!:2    NB. timeit '+/i.1000'
  83. tree=. 5!:4 @<   NB. Tree 'exp'
  84.  
  85. t=. >;:'NA NA noun verb adverb conjunction other'
  86. type=. {&t@(4!:0@<)  NB. No need to "fix" this
  87. erase 't'
  88.  
  89. wdfe=. write~ ,&eof@(;@(,&cr&.>@(<;.1~ =&lf)))@]
  90. NB. Write DOS File from Edited Lines:  'out.fil' wdfe xx=. edit ''
  91.  
  92. wsnl=. 2!:1@<    NB. List of names in locale. x=. list 'stat.ws'
  93.  
  94. write=. 1!:2 <   NB. Write string (left) to file (right)
  95. NB.  'Now is the time' write 'out0.fil'
  96. NB.  (,x,"1 cr,lf) write 'out1.fil' [ x=. ":i.3 4
  97.  
  98. writes=. 1!:2&2  NB. Write on Screen: x=. writes 'This message'
  99.  
  100. xedit=. ".&.>@(<;._1~ =&lf)
  101. NB. Execute Edited Lines, giving boxed results:  x=. xedit editor ''
  102. NB. Function definitions cannot be executed by (".)
  103. NB. Write a DOS file; then execute it as a script.
  104. NB. -----------------------------------------
  105. script=. 0!:2&<
  106. NB. 'out.fil' script 'in.fil'   OR   script 'in.fil
  107. NB.  OR   'out.fil' script ''
  108.  
  109. sscript=. 0!:3@< NB. Silent Script
  110.  
  111. off=. 0!:55      NB. Return to DOS with:    off 0
  112. NB.  Return to DOS with:   Ctrl d   <Enter>
  113.